package com.mrd.gtimpframe.entity;

import java.io.Serializable;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.mrd.util.StringUtils;

/**
 * 业务操作记录
 * Created by Dengdc on 2017-11-16
 */
public class DeclaOperationRecord implements Serializable {
    /**
     * ID
     */
    private String id;

    /**
     * 报关单ID
     */
    private String did;

    /**
     * 业务编码
     */
    private String businessNo;

    /**
     * 操作项目代码
     */
    private String recItemCode;

    /**
     * 其他操作项目
     */
    private String otherRecItem;

    /**
     * 备注说明
     */
    private String remark;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 创建人
     */
    private String creator;

    /**
     * 最后修改时间
     */
    private Date modifyTime;

    /**
     * 修改人
     */
    private String modifier;

    /**
     * 状态，保留字段
     */
    private String status;

    /**
     * 删除标识，0 未删除，1 已删除
     * 保留字段
     */
    private String delFlag;



    public enum OperationEnum{
        /**
         * 客户提交，在用户支付完成时使用
         */
        CUSTOMER_SUBMIT,
        /**
         * 客户申请驳回
         */
        CUSTOMER_APPLY_REJECT,
        /**
         * 供应商处理驳回申请
         */
        SUPPLIER_ACCEPT_REJECT,
        /**
         * 供应商驳回
         */
        SUPPLIER_REJECT_SUBMIT,
        /**
         * 供应商受理
         */
        SUPPLIER_ACCEPT_SUBMIT,
        /**
         * 第二供应商受理
         */
        SUPPLIER_SEC_ACCEPT_SUBMIT,
        /**
         * 供应商退单
         */
        SUPPLIER_CHARGE_BACK,
        /**
         * 供应商广州单一窗口上传
         */
        SUPPLIER_GZ_SW_UPLOAD,
        /**
         * 供应商国版单一窗口上传
         */
        SUPPLIER_CN_SW_UPLOAD,
        /**
         * 供应商国版单一窗口上传
         */
        SUPPLIER_QP_UPLOAD,
        /**
         * 供应商更新查验：查验中
         */
        SUPPLIER_VERIFY_ING,
        /**
         * 供应商更新查验：查验完成
         */
        SUPPLIER_VERIFY_DONE,
        /**
         * 供应商更新查验：查验不通过
         */
        SUPPLIER_VERIFY_FAIL,
        /**
         * 供应商更新查验：海关放行
         */
        SUPPLIER_VERIFY_CT_PASS,
        /**
         * 供应商更新查验：商检放行
         */
        SUPPLIER_VERIFY_SJ_PASS,
        /**
         * 供应商更新查验：其他放行
         */
        SUPPLIER_VERIFY_OT_PASS,
        /**
         * 单证待申领
         */
        DOC_WAIT,
        /**
         * 单证申领中
         */
        DOC_RECEIVING,
        /**
         * 单证已申领
         */
        DOC_RECEIVED,
        /**
         * 单证已发送
         */
        DOC_SEND,
        /**
         * 现场放行
         */
        SCENE_RELEASE,
        /**
         * 其他
         */
        OT_REC;
        public String cnString(){
            String[] txtArr = {"已支付", "申请驳回", "受理驳回", "已驳回", "已受理", "已受理", "已退单"
            , "申报中", "申报中", "申报中", "查验中", "查验完成", "查验不通过", "查验：海关放行"
            , "查验：商检放行", "查验：其他放行", "单证待申领", "单证申领中", "单证已申领", "单证已发送", "现场放行", "其他"};
            OperationEnum[] oes = OperationEnum.values();
            for (int i = 0; i < oes.length; i++) {
                OperationEnum oe = oes[i];
                if(oe.equals(this)){
                    return txtArr[i];
                }
            }
            return this.toString();
        }

        public static OperationEnum newInstanceFormStringCode(String code){
            OperationEnum[] oes = OperationEnum.values();
            for (OperationEnum oe : oes) {
                if (oe.toString().equals(code)) {
                    return oe;
                }
            }
            return OT_REC;
        }
    }

    private static final long serialVersionUID = 1L;

    public DeclaOperationRecord(String id, String did, String businessNo, String recItemCode, String otherRecItem, String remark, Date createTime, String creator, Date modifyTime, String modifier, String status, String delFlag) {
        this.id = id;
        this.did = did;
        this.businessNo = businessNo;
        this.recItemCode = recItemCode;
        this.otherRecItem = otherRecItem;
        this.remark = remark;
        this.createTime = createTime;
        this.creator = creator;
        this.modifyTime = modifyTime;
        this.modifier = modifier;
        this.status = status;
        this.delFlag = delFlag;
    }

    public DeclaOperationRecord() {
        super();
    }

    public static DeclaOperationRecord newInstance(String did, String businessNo, OperationEnum opItem, String remark, String creator){
        DeclaOperationRecord record = new DeclaOperationRecord();
        record.setId(StringUtils.getUUID());
        record.setDid(did);
        record.setRecItemCode(opItem.toString());
        record.setCreateTime(new Date());
        record.setCreator(creator);
        record.setBusinessNo(businessNo);
        record.setRemark(remark);
        return record;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getDid() {
        return did;
    }

    public void setDid(String did) {
        this.did = did == null ? null : did.trim();
    }

    public String getBusinessNo() {
        return businessNo;
    }

    public void setBusinessNo(String businessNo) {
        this.businessNo = businessNo == null ? null : businessNo.trim();
    }

    public String getRecItemCode() {
        return recItemCode;
    }

    public void setRecItemCode(String recItemCode) {
        this.recItemCode = recItemCode == null ? null : recItemCode.trim();
    }

    public String getOtherRecItem() {
        return otherRecItem;
    }

    public void setOtherRecItem(String otherRecItem) {
        this.otherRecItem = otherRecItem == null ? null : otherRecItem.trim();
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark == null ? null : remark.trim();
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator == null ? null : creator.trim();
    }

    public Date getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }

    public String getModifier() {
        return modifier;
    }

    public void setModifier(String modifier) {
        this.modifier = modifier == null ? null : modifier.trim();
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status == null ? null : status.trim();
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag == null ? null : delFlag.trim();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", did=").append(did);
        sb.append(", businessNo=").append(businessNo);
        sb.append(", recItemCode=").append(recItemCode);
        sb.append(", otherRecItem=").append(otherRecItem);
        sb.append(", remark=").append(remark);
        sb.append(", createTime=").append(createTime);
        sb.append(", creator=").append(creator);
        sb.append(", modifyTime=").append(modifyTime);
        sb.append(", modifier=").append(modifier);
        sb.append(", status=").append(status);
        sb.append(", delFlag=").append(delFlag);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        DeclaOperationRecord other = (DeclaOperationRecord) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getDid() == null ? other.getDid() == null : this.getDid().equals(other.getDid()))
            && (this.getBusinessNo() == null ? other.getBusinessNo() == null : this.getBusinessNo().equals(other.getBusinessNo()))
            && (this.getRecItemCode() == null ? other.getRecItemCode() == null : this.getRecItemCode().equals(other.getRecItemCode()))
            && (this.getOtherRecItem() == null ? other.getOtherRecItem() == null : this.getOtherRecItem().equals(other.getOtherRecItem()))
            && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getCreator() == null ? other.getCreator() == null : this.getCreator().equals(other.getCreator()))
            && (this.getModifyTime() == null ? other.getModifyTime() == null : this.getModifyTime().equals(other.getModifyTime()))
            && (this.getModifier() == null ? other.getModifier() == null : this.getModifier().equals(other.getModifier()))
            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
            && (this.getDelFlag() == null ? other.getDelFlag() == null : this.getDelFlag().equals(other.getDelFlag()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getDid() == null) ? 0 : getDid().hashCode());
        result = prime * result + ((getBusinessNo() == null) ? 0 : getBusinessNo().hashCode());
        result = prime * result + ((getRecItemCode() == null) ? 0 : getRecItemCode().hashCode());
        result = prime * result + ((getOtherRecItem() == null) ? 0 : getOtherRecItem().hashCode());
        result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getCreator() == null) ? 0 : getCreator().hashCode());
        result = prime * result + ((getModifyTime() == null) ? 0 : getModifyTime().hashCode());
        result = prime * result + ((getModifier() == null) ? 0 : getModifier().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getDelFlag() == null) ? 0 : getDelFlag().hashCode());
        return result;
    }
}
